<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta
      http-equiv="X-UA-Compatible"
      content="IE=edge"
    />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0"
    />
    <title>Document</title>
    <link
      rel="stylesheet"
      href=""
    />
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      .nav,
      .nav-fixed {
        width: 100%;
        height: 50px;
        background-color: aqua;
      }

      .nav-fixed {
        position: fixed;
        left: 0;
        top: -50px;
        opacity: 0;
        background-color: cadetblue;
        transition: top 1s;
      }

      .nav-fixed.active {
        opacity: 1;
        top: 0;
      }

      .goods {
        height: 500vh;
      }
    </style>
  </head>
  <body>
    <div class="nav"></div>
    <div class="nav-fixed"></div>
    <div class="goods"></div>
    <script src=""></script>
    <script>
      const fixedNav = document.querySelector('.nav-fixed')
      onscroll = () => {
        const tops = document.documentElement.scrollTop
        if (tops > 200) {
          fixedNav.classList.add('active')
        } else {
          fixedNav.classList.remove('active')
        }
      }
    </script>
  </body>
</html>
